﻿using UnityEngine;

public class BulletEx : MonoBehaviour {
	// 子弹的移动速度
	public float speed = 0.5f;

	// 攻击力
	public int power = 1;

	// 旋转角
	public float angle = 90.0f;

	public float rotation  = 0.1f;

	public Rigidbody2D rigidbody2;


	// 随时间推移加速度(转大圈)
	public float addSpeed = 0.2f;

	private void Update() {
		
		float posX,posY = 0.0f;

		posX = Mathf.Cos(angle*Mathf.PI/180.0f);
		posY = Mathf.Sin(angle*Mathf.PI/180.0f);

		// 单位化向量
		var v = new Vector2(posX,posY).normalized;

		// 改变方向
		this.rigidbody2.velocity = v * speed;

		// 旋转
		angle+= rotation;

		speed += addSpeed;
		
	}
}
